<?php

class ButtonColumn extends CButtonColumn {

    public $template = '{update}';
    public $buttons = array('update', 'inactive', 'active');

    protected function renderButton($id, $button, $row, $data) {
        if (isset($button['visible']) && !$this->evaluateExpression($button['visible'], array('row' => $row, 'data' => $data)))
            return;
        $url = isset($button['url']) ? $this->evaluateExpression($button['url'], array('data' => $data, 'row' => $row)) : '#';
        $title = isset($button['title']) ? $button['title'] : '';
        $dialogWidth = isset($button['dialog-width']) ? $button['dialog-width'] :'';
        $dialogHeight = isset($button['dialog-height']) ? $button['dialog-height'] :'';
        $updateUrl = url(app()->controller->id."/update/".$data->id);
        if($url != '#')
            $updateUrl = $url;
        switch ($id) {
            case 'update':
                echo Html::buttonInGrid('linkEdit', $updateUrl, 'Edit', $title, 'icon edit update-dialog-open-link', $dialogWidth, $dialogHeight);
                break;
            case 'updateHasFile':
                echo Html::buttonInGrid('linkEdit', $updateUrl, 'Edit', $title, 'icon edit update-file-dialog-open-link', $dialogWidth, $dialogHeight);
                break;
            case 'active':
                echo Html::buttonInGrid('linkActive', '', 'Active', '', 'icon active', '', '', array('onclick'=>'LGCMS.ajaxCallback("' . $url . '")'));
                break;
            case 'inactive':
                echo Html::buttonInGrid('linkInactive', '', 'InActive', '', 'icon inactive', '', '', array('onclick'=>'LGCMS.ajaxCallback("' . $url . '")'));
                break;
            case 'conversation':
                echo Html::buttonInGrid('linkConversation', $url, 'Conversations', $title, 'icon conversation update-dialog-open-link', $dialogWidth, $dialogHeight);
                break;
            case 'note':
                echo Html::buttonInGrid('linkNote', $url, 'Notes', $title, 'icon note update-dialog-open-link', $dialogWidth, $dialogHeight);
                break;
            case 'function':
                echo Html::buttonInGrid('linkFunction', $url, 'Funtions', $title, 'icon function update-dialog-open-link', $dialogWidth, $dialogHeight);
                break;
            //article
            case 'restore':
                echo Html::buttonInGrid('linkRestore', '', 'Restore', '', 'icon restore', '', '', array('onclick'=>'LGCMS.ajaxCallback("' . $url . '")'));
                break;
            case 'delete_forever':
                echo Html::buttonInGrid('linkDeleteForever', '', 'Delete Forever', '', 'icon delete', '', '', array('onclick'=>'LGCMS.ajaxCallback("' . $url . '")'));
                break;
            //client
            case 'permission':
                $class='icon add_user';
                //echo Html::buttonPermissionInGrid('linkPermission', $url, 'Permission', '', 'icon viewcomment');
                echo Html::linkInGrid($title,$url,$class);
                break;
            case 'custom_field':
                $class='icon custom_field';
                //echo Html::buttonPermissionInGrid('linkPermission', $url, 'Permission', '', 'icon viewcomment');
                echo Html::linkInGrid($title,$url,$class);
                break;
            case 'issue_field':
                $class='icon issue_field';
                echo Html::linkInGrid($title,$url,$class);
                break;
            case 'editfield':
                echo Html::buttonInGrid('editfield', $url, 'Edit', 'Edit Field', 'icon edit update-dialog-open-link', $dialogWidth, $dialogHeight);
                break; 
        }
    }

}

?>